package com.example.demo.lock;

import java.util.concurrent.CountDownLatch;

public class SynTest{

    private static int race = 0;

    private static final CountDownLatch latch = new CountDownLatch(2);

    public static void main(String[] args) throws InterruptedException {
        for (int i =0; i<2;i++){
            new Thread(()->{
                for (int j =0 ;j<10000;j++){
                    synchronized (SynTest.class){
                        race++;
                    }
                }
                latch.countDown();
            }).start();
        }
        latch.await();
        System.out.println(race);
    }

}
